#ifndef CONFIG_H
#define CONFIG_H

#include <iostream>
#include <QFile>
#include <QMap>
#include <QString>
#include <QSettings>

class Config {

public:

    /**
     * @brief getInstance 获取实例
     * @return
     */
    static Config& getInstance();

    /**
     * 获取指令集合
     */
    QMap<QString, QString>& directs();

    /**
     * @brief addDirect 添加指令
     * @param key
     * @param val
     */
    void addDirect(QString key, QString val);

    /**
     * @brief deleteDirect 删除指令
     * @param key
     */
    void deleteDirect(QString key);


    /**
     * @brief saveConfig 保存文件
     */
    void saveDirects();

private:

    Config();

    ~Config();

    Config(const Config& config) = delete;

    Config& operator=(const Config& config) = delete;

private:

    QSettings* m_settings = nullptr;

    QMap<QString, QString> m_directs;   //保存指令集合

};

#endif // CONFIG_H
